<?php

namespace App\Console\Commands\Tasks;
use App\Repositories\Activity\CarnivalMatchRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class Carnival2022Command extends Command
{
    protected $signature = 'task:carnival2022';
    protected $description = '房间巅峰赛活动结算脚本';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        sleep(20); //防止主从延迟读取的数据不准
        $preMsg = '比赛结算:';
        try {
            $repo = new CarnivalMatchRepository();
//            Log::info(" $preMsg start");
            $initResult = $repo->initMatch();
            if ($initResult) {
//                Log::info(" $preMsg 初始化success");
            }
            $repo->settle();
//            Log::info("$preMsg end");

        } catch (\Throwable $exception) {
            Log::error("$preMsg error :". $exception->getMessage());
        }

    }

}
